# -*- coding: utf-8 -*-
'''
Created on 2013-4-3

@author: chenkaode@baidu.com
'''

from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4 import uic
from PyQt4 import QtCore, QtGui
from ui import ui_main
from util.PhoneUtil import *
from util.UbcUtil import *

QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) 

class MainWin(QMainWindow,ui_main.Ui_TestHelperWindow):
    def __init__(self,parent=None):
        super(MainWin,self).__init__(parent)
        self.setupUi(self)
        self.connect(self.connectWifiBtn,SIGNAL("clicked()"),self.connectWifi)
        self.connect(self.showUbcDBBtn,SIGNAL("clicked()"),self.showUbcDB)
    
    def connectWifi(self):
        PhoneUtil.connectWifi()
        self.ioTextEdit.setText(self.tr("已完成wifi连接"))
        
    def showUbcDB(self):
        ret = UbcUtil.DBContent()
        txt = "_id:metric_id\n"
        for t in ret:
            txt = txt + str(t[0]) + ":" + str(t[1]) + "\n" 
        print txt
        self.ioTextEdit.setText(txt)
